home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Help / locale / help / english / sys / if.doc < prev    next >
Encoding:
Text File  |  2000-10-06  |  2.2 KB  |  100 lines

  1. IF
  2.  
  3. Evaluates conditional operations in script files.
  4.  
  5. Format
  6.  
  7. IF [NOT] [WARN | ERROR | FAIL] [<string> EQ| GT | GE <string>] [VAL] [EXISTS
  8. <filename>]
  9.  
  10. Template
  11.  
  12. NOT/S,WARN/S,ERROR/S,FAIL/S,EQ/K,GT/K,GE/K,VAL/S,EXISTS/K
  13.  
  14. Location
  15.  
  16. Internal
  17.  
  18. In a script file, IF, when its conditional is true, carries out all the
  19. subsequent commands until an ENDIF or ELSE command is found. IF must be used
  20. in conjunction with ENDIF, however, ELSE is optional. When the conditional is
  21. not true, execution skips directly to the ENDIF or to an ELSE. The conditions
  22. and commands in IF and ELSE blocks can span more than one line before their
  23. corresponding ENDIFs.
  24.  
  25. Nested Ifs jump to the matching ENDIF.
  26.  
  27. The additional keywords are as follows:
  28.  
  29. NOT
  30.  
  31. Reverses the interpretation of the result.
  32.  
  33. WARN
  34.  
  35. True if previous return code is greater than or equal to 5.
  36.  
  37. ERROR
  38.  
  39. True if previous return codes is greater than or equal to 10; only available
  40. if FAILAT is set to greater than 10.
  41.  
  42. FAIL
  43.  
  44. True if previous return code is greater than or equal to 20; only available
  45. if FAILAT is set to greater than 20.
  46.  
  47. <a> GT <b>
  48.  
  49. True if the test of a is greater than the text of b (disregarding case). Use
  50. NOT GT for less than.
  51.  
  52. <a> GE <b>
  53.  
  54. True if the text of a is greater than or equal to the text of b (disregarding
  55. case). Use NOT GE for less than or equal to.
  56.  
  57. <a> EQ <b>
  58.  
  59. True if the text of a and b is identical (disregarding case).
  60.  
  61. VAL
  62.  
  63. Specifies a numeric comparison.
  64.  
  65. EXISTS <file>
  66.  
  67. True if the file exists.
  68.  
  69. If more than one of the three condition-flag keywords (WARN, ERROR, FAIL) are
  70. given, the one with the lowest value is used.
  71.  
  72. You can use local or global variables with IF by prefacing the variable name
  73. with a $ character.
  74.  
  75. Example 1:
  76.  
  77. IF EXISTS Work/Prog
  78. TYPE Work/Prog HEX
  79. ELSE
  80. ECHO "It's not here"
  81. ENDIF
  82.  
  83. AmigaDOS displays the file Work/Prog if it exists in the current directory.
  84. Otherwise, AmigaDOS displays the message It's not here and continues after
  85. the ENDIF.
  86.  
  87. Example 2:
  88.  
  89. IF ERROR
  90. SKIP errlab
  91. ENDIF
  92. ECHO "No error"
  93. LAB errlab
  94.  
  95. If the previous command produces a return code greater than or equal to 10,
  96. AmigaDOS skips over the ECHO command to the errlab label.
  97.  
  98. See also: EXECUTE, FAILAT, LAB, QUIET, SKIP. For more examples using the IF
  99. command, see Chapter 8.
  100.